package com.huohua.jobschduler.model.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Set;
@Data
@TableName("job_details")
public class Job implements IJob{
    @TableId(value = "id")
    private String id;
    @TableField(value = "instance_id")
    private String instanceId;
    @TableField(value = "output_direction")
    private String outputDirection;
    @TableField(value = "dependency_event")
    private String dependencyEvent;
    @TableField(value = "instance_status")
    private String instanceStatus;

    @Override
    public Boolean isSuccess() {
        return this.instanceStatus.equals(JobStatus.SUCCESS.getCode());
    }

    @Override
    public Boolean isFail() {
        return this.instanceStatus.equals(JobStatus.FAIL.getCode());
    }

    @Override
    public Boolean isUnprocessed() {
        return this.instanceStatus.equals(JobStatus.UNPROCESSED.getCode());
    }

    @Override
    public Boolean in(Set<String> set) {
        return set.contains(this.instanceId);
    }

    @Override
    public Boolean equalsJobId(String jobId) {
        return this.instanceId.equals(jobId);
    }

    @Override
    public String uniqueId() {
        return this.instanceId;
    }
}
